package com.atguigu.phoenix;

import java.sql.*;

/**
 * @author yhm
 * @create 2023-02-10 16:03
 */
public class PhoenixConnect {
    public static void main(String[] args) throws SQLException {
        // 1. 驱动  url  账号 密码
        String url = "jdbc:phoenix:hadoop102,hadoop103,hadoop104:2181";

        // 2. 获取连接
        Connection connection = DriverManager.getConnection(url);

        // 3. 使用连接
        PreparedStatement ps = connection.prepareStatement("select * from student");
        ResultSet resultSet = ps.executeQuery();

        // 4. 打印数据
        while (resultSet.next()) {
            System.out.println(resultSet.getString(1) + "-" + resultSet.getString(2)+"-" + resultSet.getString(3) + "-" + resultSet.getString(4));
        }

        // 5. 关闭连接
        ps.close();
        connection.close();
    }
}
